/*
 * IntSet.java
 * 
 * Copyright 2004 Christoph Csallner and Yannis Smaragdakis.
 */
package edu.gatech.cc.cnc.params;

import junit.framework.TestCase;
import client.Cut;
import client.CutReflect;
import edu.gatech.cc.cnc.sym;

/**
 * @author csallner@gatech.edu (Christoph Csallner)
 */
public class ParamIntTest extends TestCase {

  protected final CutReflect cut = new CutReflect(); 
  
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    
    ParamInt.resetSolver();
    ParamRefType.resetEq();
    Param.resetNames(cut.array(), Cut.class);
  }
  
  
  public void testConstrain() {
    ParamInt x = new ParamInt("x");
    x.constrain(sym.EQ, "12");
    
    ParamInt y = new ParamInt("y");
    y.constrain(sym.GEQ, "10");
    y.constrain(sym.NEQ, "10");
    y.constrain(sym.NEQ, "11");
    y.constrain(sym.NEQ, x);
    y.constrain(sym.LEQ, "13");
    
    ParamInt.prepareSolution(new ParamInt[]{x,y});
    ParamInt.generateSolution();
    assertEquals(12, x.getValue());
    assertEquals(13, y.getValue());
  }
  
  
  public void testGetPlan() {
    ParamInt x = new ParamInt("x");
    x.constrain(sym.EQ, "100");
    
    ParamInt y = new ParamInt("y");
    x.constrain(sym.EQ, y);

    ParamInt.prepareSolution(new ParamInt[]{x,y});
    ParamInt.generateSolution();
    assertEquals("int i1 = 100;", x.getPlan().text());
    assertEquals("int i2 = 100;", y.getPlan().text());
  }  
}
